

Function.prototype.setOverload = function(fn){
    var oldTarget = this;
    oldTarget = function(){
        console.log("!");
        if (arguments.length === fn.length) {
            return fn.apply(this, arguments);
        } else {
            return oldTarget.apply(this, arguments);
        }
    };
};

function method(){
    return "没找到对应重载";
}
method.setOverload(function(a){return a;});
method.setOverload(function(a,b){return a+b;});
console.log(method(1));
console.log(method(1,2));